#include <service/ChatService.h>

ChatService *chat_service = new ChatService;

void ChatService::set(network::ClientConnection *connection)
{
    connections.insert(connection); // bl
}
void ChatService::send(network::ClientConnection *self, const std::string &msg)
{
    for (auto conn : connections)
    {
        if(conn==self)
        {
            continue;
        }
        conn->send(msg);
    }
   
}
void ChatService::remove(network::ClientConnection *connection)
{
    auto it = connections.find(connection);
    if (it != connections.end())
    {
        connections.erase(it);
    }
}